public class Test {
    public static void main(String[] args) {
        Object object = new Object();
        Thread t1 = new Thread(()-> {
           synchronized (object){
               System.out.println("上锁之前");

               try {
                   object.wait();
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
               System.out.println("上锁之后");
           }
        });

        Thread t2 = new Thread(()-> {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (object){
                System.out.println("进行通知");
                object.notify();
            }
        });


        t1.start();
        t2.start();
    }
}
